package com.sikaryofficial.system.api.config;

import feign.codec.Decoder;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.cloud.openfeign.support.HttpMessageConverterCustomizer;
import org.springframework.cloud.openfeign.support.SpringDecoder;
import org.springframework.context.annotation.Bean;

import java.util.HashMap;
import java.util.Map;

public class HiSMKDigClientConfiguration {

    @Bean
    public Decoder feignDecoder(ObjectFactory<HttpMessageConverters> messageConverters,
                                ObjectProvider<HttpMessageConverterCustomizer> customizers) {
        Map<String, DecryptComponent> decryptComponents = new HashMap<>();
        decryptComponents.put("AES", new AESDecryptComponent());
        return new HiSMKDigResponseDecoder(new SpringDecoder(messageConverters, customizers), decryptComponents);
    }
}
